﻿using System;
using System.Web;

namespace MikeKappel.Com.CS
{
    public static partial class Helper
    {
        public static void SetContentType(HttpApplication app, String extension)
        {
            if (extension == "htm" ||
                extension == "html" ||
                extension == "asp" ||
                extension == "aspx" ||
                extension == "php")
            {
                app.Context.Response.ContentType = "text/html";
            }
            else if (extension == "txt")
            {
                app.Context.Response.ContentType = "text/plain";
            }
            else if (extension == "pdf")
            {
                app.Context.Response.ContentType = "application/pdf";
            }
            else if (extension == "xml")
            {
                app.Context.Response.ContentType = "text/xml";
            }
            else if (extension == "ico")
            {
                app.Context.Response.ContentType = "image/x-icon";
            }
            else if (extension == "jpg")
            {
                app.Context.Response.ContentType = "image/jpeg";
            }
            else if (extension == "gif")
            {
                app.Context.Response.ContentType = "image/gif";
            }
            else if (extension == "icon")
            {
                app.Context.Response.ContentType = "image/x-icon";
            }
            else if (extension == "png")
            {
                app.Context.Response.ContentType = "image/png";
            }
            else if (extension == "torrent")
            {
                app.Context.Response.ContentType = "application/octet-stream";
            }
        }
    }
}